﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Espam.Idiomas.Decimo.Tesis.Negocio;
using System.Globalization;
using System.Speech.Synthesis;

using System.IO;
namespace Espam.Idiomas.Decimo.Tesis.Web

{
    public partial class Default : System.Web.UI.Page
    {
       // SpeechSynthesizer AVJarvis = new SpeechSynthesizer();
        string validaSession ;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
                Response.Cache.SetAllowResponseInBrowserHistory(false);
                Response.Cache.SetNoStore();

                if (Session["userEspamIdiomasVarSession001"] == null || Session["rolEspamIdiomasVarSession003"] == null)
                {
                    validaSession = "NoHaIniciadoSession";
                    Response.Redirect("UI_Login.aspx?validaSession=" + validaSession);
                }
                else if (Session["userEspamIdiomasVarSession001"] != null && Session["rolEspamIdiomasVarSession003"].ToString() == "Docente")
                {
                    Response.Redirect("UI_DashboardTeacher.aspx");
                }
                else if (Session["userEspamIdiomasVarSession001"] != null && Session["rolEspamIdiomasVarSession003"].ToString() == "Administradores")
                {
                    DatosPanel();
                   //AVJarvis.SpeakAsync("NECESITO MI AVAL POR FAVOR");
                    //AVJarvis.SpeakAsyncCancelAll();
                   
                   
                }
                else if (Session["userEspamIdiomasVarSession001"] != null && Session["rolEspamIdiomasVarSession003"].ToString() == "Alumno")
                {
                    Response.Redirect("UI_DashboardStudents.aspx");
                }
            }
        }

        private void voz()
        {
            //SpVoice voice = new SpVoice();
            //voice.Speak("SESION INICIADA COMO " + Session["lastNameEspamIdiomasVarSession005"] + Session["nameEspamIdiomasVarSession006"]);
        }

        private void DatosPanel()
        {
            Admin oAdmin = new Admin();
            List<Admin> lista = new List<Admin>();
            lista = oAdmin.getDatosPanelAdmin();
            CultureInfo ci = new CultureInfo("es-Es");
            lblDateAndHour.Text = " "+CapitalizeFirstLetter(ci.DateTimeFormat.GetDayName(DateTime.Today.DayOfWeek))+" "+ DateTime.Today.Day+" de "+CapitalizeFirstLetter(ci.DateTimeFormat.GetMonthName(DateTime.Now.Month))+", "+DateTime.Today.Year;
            if (lista.Count>0)
            {
                lblNUsuarios.Text=lista[0].nUsuarios.ToString();
                lblNUbicaciones.Text = lista[0].nUbicaiciones.ToString();
                lblNMatriculados.Text = lista[0].nMatriculados.ToString();
                lblNModulos.Text=lista[0].nModulos.ToString();
                lblNDocentes.Text = lista[0].nDocentes.ToString();
                lblNNiveles.Text=lista[0].nNiveles.ToString();
            }
        }
        private string CapitalizeFirstLetter(string val)
        {
            return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(val);
            
        }
       
    }
}